package com.kimo3412.gradehub.service;


import com.kimo3412.gradehub.entity.Student;
import com.kimo3412.gradehub.repository.StudentRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentService {

    @Autowired
    private StudentRepository studentRepository;

    public List<Student> findAllStudents() {
        return studentRepository.findAll();
    }

    public Student findStudentById(Long studentId) {
        return studentRepository.findById(studentId).orElse(null);
    }

    public Student addStudent(Student student) {
        return studentRepository.save(student);
    }
}
